<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {% block title %}
    {% endblock %}
    <title>数据资源目录</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <link rel="shortcut icon" href="/static/favicon.ico">
    <style>
        .web-title-main {
            font-size: 24px
        }

        .userinfo-items {
            float: right
        }

        .main-content {
            margin-top: 18px
        }

        body {
            background-color: #F2F2F2;
        }

        .require_i {
            color: #FF5722;
        }
    </style>
    {% block customcss %}
    {% endblock %}
</head>
<body>
<ul class="layui-nav">
    <li class="layui-nav-item web-title-main" style="padding-right: 30px">
        <h1>
            <a href="/" style="display: inline;padding: 0 10px;font-size: 24px;color: #fff">
                <img src="/static/images/logo.png" alt="" style="padding-bottom: 2px;">
                数据资源目录
            </a>
        </h1>
    </li>
    <li class="layui-nav-item {% if request.path == '/' %}layui-this {% endif %}"><a href="/">首页</a></li>

    <li class="layui-nav-item {% if request.path == '/resource/search/' %}layui-this {% endif %}"><a
            href="/resource/search"></a>
        <a href="javascript:;">资源检索</a>
        <dl class="layui-nav-child">
          <dd><a href="/resource/search">数据资源检索</a></dd>
          <dd><a href="/resource/ftpsearch">FTP资源检索</a></dd>
        </dl>
    </li>
    <li class="layui-nav-item {% if request.path == '/resource/index/' %}layui-this {% endif %}"><a
            {% if not request.session.user_id %}target="_blank"{% endif %}
            href="#">资源创建</a>
        <dl class="layui-nav-child">
          <dd><a href="/resource/index/1">数据库资源创建</a></dd>
          <dd><a href="/resource/index/2">FTP资源创建</a></dd>
        </dl>
    </li>

    <li class="layui-nav-item {% if request.path == '/data_source/' %}layui-this {% endif %}">
{#        <a {% if not request.session.user_id %}target="_blank"{% endif %} href="/data_source/">数据源管理</a>#}
        <a href="javascript:;">数据源管理</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
          <dd><a {% if not request.session.user_id %}target="_blank"{% endif %} href="/data_source/">数据库源管理</a></dd>
          <dd><a {% if not request.session.user_id %}target="_blank"{% endif %} href="/data_source/ftp_source/">FTP源管理</a></dd>
        </dl>
    </li>
    <li class="layui-nav-item {% if request.path == '/mulu/ztree/' %}layui-this {% endif %}"><a
            {% if not request.session.user_id %}target="_blank"{% endif %} href="/mulu/ztree/">目录管理</a></li>
    <li class="layui-nav-item {% if '/user/' in request.path and request.path != '/user/center/' and request.path != '/user/password_html/' %}layui-this {% endif %}">
        <a
                href="/user/account_manage/" {% if not request.session.user_id %}target="_blank"{% endif %}>系统管理</a>
    </li>

    {% if request.session.user_id %}

        <li class="layui-nav-item userinfo-items {% if request.path == '/user/center/' or request.path == '/user/password_html/' %}layui-this {% endif %}">
            <a href="/user/center/">{{ request.session.username }}</a>
            <dl class="layui-nav-child">
                <dd><a href="/user/center/">基本资料</a></dd>
                <dd><a href="/user/password_html/">修改密码</a></dd>
                <dd><a href="/user/logout/">退出</a></dd>
                {#                    <dd><a href="">安全设置</a></dd>#}
            </dl>
        </li>
        {#        {% if request.session.level_id != 0 %}#}
        <li class="layui-nav-item userinfo-items">
            <a href="/user/message/0/">
                <i class="layui-icon layui-icon-notice" style="font-size: 16px;"></i>
                <!-- 如果有新消息，则显示小圆点 -->
                <span class="layui-badge-dot" id="new_badge" style="display:none;margin: -10px 10px 0"></span>
            </a>
        </li>
        {#        {% endif %}#}
    {% else %}
        <li class="layui-nav-item userinfo-items"><a target="_blank" href="/user/login/">登录</a></li>
    {% endif %}
</ul>

<div class="layui-container main-content">
    <div class="layui-row">
        <div class="layui-col-xs12" style="padding-top: 10px;">
            {% block content %}
            {% endblock %}

        </div>
    </div>
</div>
<script src="/static/layui/layui.js"></script>
<script src="/static/jquery/jquery.min.js"></script>
<script>
    layui.use('element', function () {
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块

        //监听导航点击
        element.on('nav(demo)', function (elem) {
            //console.log(elem)
            layer.msg(elem.text());
        });
    });
    $(function () {
        $.ajax({
                type: 'get',
                url: '/user/resource/msg_review_count/',
                dataType: 'json',
                success: function (data) {
                    // 大于99，只显示99+
                    var new_msg_count = data.new_msg_count <= 99 && data.new_msg_count >= 0 ? data.new_msg_count : '99+',
                        review_count = data.review_count <= 99 && data.review_count >= 0 ? data.review_count : '99+';
                    // 如果new_msg_count数量为0，则新消息栏和右上角铃铛处不显示徽章，如果大于0，则新消息栏显示数字，右上角显示圆点
                    var msg_span = $('#message a span[class="layui-badge"]');
                    var review_span = $('#review a span[class="layui-badge"]');
                    if (new_msg_count == 0) {
                        msg_span.hide();
                        $('#new_badge').hide();
                    } else {
                        msg_span.text(new_msg_count).show();
                        $('#new_badge').show();
                    }
                    // 待审核显示数字徽章
                    if (review_count == 0) {
                        review_span.hide()
                    } else {
                        review_span.text(review_count).show();
                    }
                }
            }
        );
    })
</script>
{% block customjs %}
{% endblock %}
</body>
</html>